#!/usr/bin/env python

import random
import string
s='abcdefghijklmnopqrstuvwxyz'
s2=[]
for i in range(100):
    str_lst=random.choices(s,k=2)
    s2.append(str_lst[0] + str_lst[1])
str_set=set(s2)
str_dict={i:s2.count(i) for i in str_set}
str_sort=sorted(str_dict.items(), reverse=True)
print(str_sort)

print('#' * 100)

str_list=[''.join(random.choices(string.ascii_lowercase,k=2)) for i in range(100)]
str_set=set(str_list)
str_dict={i:str_list.count(i) for i in str_set}
#str_sort=sorted(str_dict.items(), reverse=True)
str_sort=sorted(str_dict.items(), key=lambda item: item[1], reverse=True)
print(str_sort) # 改的不错


# 没有按出现次数排序，你可以看看哪里出了错
